package com.hui.server.config.mybatis;

import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;
import java.util.Date;

/**
 * @BelongsProject: yeb
 * @BelongsPackage: com.hui.server.config.mybatis
 * @Author: HUI
 * @CreateTime: 2022-04-08 09:27
 * @Description: 自动填充策略
 */
@Component
@Slf4j
public class MyMetaObjectHandler implements MetaObjectHandler {
    //插入时填充策略
    @Override
    public void insertFill(MetaObject metaObject) {
        this.setFieldValByName("createDate", LocalDateTime.now(), metaObject);


    }

    //更新时填充策略
    @Override
    public void updateFill(MetaObject metaObject) {

    }
}
